package com.contest.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

//import javax.annotation.PostConstruct;
import java.io.File;

@Configuration
public class FileConfig {

    @Value("${file.upload.dir}")
    private String uploadDir;

//    @PostConstruct
    public void init() {
        File uploadDirectory = new File(uploadDir);
        if (!uploadDirectory.exists()) {
            uploadDirectory.mkdirs();
        }
        
        File pdfDirectory = new File(uploadDir + "/pdfs");
        if (!pdfDirectory.exists()) {
            pdfDirectory.mkdirs();
        }
    }

    public String getUploadDir() {
        return uploadDir;
    }
}